package net.araim.bbingo;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class Settings {
	private SharedPreferences settings;

	public static String SOUND_ONOFF = "SOUND_ONOFF";
	public static String BOARD_SIZE = "BOARD_SIZE";

	private static Settings s;

	public static Settings getInstance(Context ctx) {
		if (s == null) {
			synchronized (SOUND_ONOFF) {
				if (s == null) {
					s = new Settings(PreferenceManager.getDefaultSharedPreferences(ctx));
				}
			}
		}
		return s;
	}

	public boolean isSoundOn() {
		return settings.getBoolean(SOUND_ONOFF, true);
	}

	public void setSound(boolean soundOn) {
		SharedPreferences.Editor e = settings.edit();
		e.putBoolean(SOUND_ONOFF, soundOn);
		e.commit();
	}

	public int getSize() {
		return settings.getInt(BOARD_SIZE, 5);
	}

	public void setSize(int size) {
		SharedPreferences.Editor e = settings.edit();
		e.putInt(BOARD_SIZE, size);
		e.commit();
	}

	private Settings(SharedPreferences sp) {
		settings = sp;
	}

	private Settings() {

	}

}
